﻿package tests;
import flash.events.Event;
import flash.Lib;
import fpc.controls.buttons.Button;
import fpc.containers.Container;
import fpc.layouts.VLayout;
import flash.display.Shape;
import fpc.FoolProofComponents;

class FineVBoxTest extends GenericTest
{
	public function new() 
	{
		super();
	}
	
	var _container:Container<VLayout>;
	
	override function init()
	{
		FoolProofComponents.initStage(stage);
		
		var container = _container = new Container<VLayout>();
		container.addTo(this);
		container.layout = new VLayout();
		
		var layout = container.layout;
		layout.autoSize = false;
		
		var button = new Button('Button0');
		button.percentsHeight = 20;
		button.percentsWidth = 100;
		layout.add(button);
		var button = new Button('Button1');
		button.percentsWidth = 100;
		layout.add(button);
		var button = new Button('Button2');
		button.percentsWidth = 100;
		layout.add(button);
		var button = new Button('Button     3');
		button.percentsWidth = 100;
		button.percentsHeight = 10;
		layout.add(button);
		
		stage.addEventListener(Event.RESIZE, onStageResize);
		onStageResize();
	}
	
	override function resize(width:Float, height:Float)
	{
		var time = Lib.getTimer();
		_container.width = width - 100;
		_container.height = 0;
		trace(Lib.getTimer() - time);
		
		var g = graphics;
		g.clear();
		if (_container.height > stage.stageHeight + .1)
		{
			g.clear();
			g.beginFill(0xff0000);
			g.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
			g.endFill();
		}
	}
}